{include file="public:header" /}
<!--微信 设置-->
<div class="pad_lr_10 mt10">
<div class="col_tab">
	<ul class="J_tabs tab_but cu_li">
		<li class="current">微信设置</li>
	</ul>
<div class="J_panes">
	<div class="content_list pad_10">
	<form id="info_form" action="{:url('Setting/addDo')}" method="post" enctype="multipart/form-data">
	<table width="100%" class="table_form">
        <tr>
            <th width="150">公众号类型 :</th>
            <td>
                <label class="mr10"><input name="data[weixin_type]" type="radio" value="1" class="J_change_status">认证订阅号 </label>
                <label><input name="data[weixin_type]" type="radio" value="2" class="J_change_status" checked>认证服务号</label>
            </td>
        </tr>
        <tr>
            <th width="150">appid :</th>
            <td>
				<input type="text" name="data[weixin_appid]" class="input-text" size="30">
			</td>
        </tr>


		<tr>
            <th>appsecret :</th>
            <td><input type="text" name="data[weixin_appsecret]" class="input-text" value="" size="30" /></td>
        </tr>
        <tr>
            <th>token :</th>
            <td>
                <input type="text" name="data[weixin_token]" class="input-text" value="yingloujie" size="30">
            </td>
        </tr>
        <tr>
            <th>encodingaeskey :</th>
            <td>
                <input type="text" name="data[weixin_appkey]"  class="input-text" value="" size="30"/>
            </td>
        </tr>
        <tr>
            <th>Oauth 2.0</th>
            <td>在微信公众号请求用户网页授权之前，开发者需要先到公众平台网站的【开发者中心】网页服务中配置授权回调域名。回调域名请设置为：{:config('url_domain_root')}</td>
        </tr>
        <tr>
            <th>接口地址 :</th>
            <td>
                {empty name='auth_url'}<a href="{:url('Setting/index',['type'=>'site'])}">请先设置站点域名</a>{else /}{$auth_url}{/empty}
            </td>
        </tr>
        <tr>
            <th>接收消息的微信号 :</th>
            <td>
                <input type="text" name="data['weixin']" class="input-text" size="30"><span><span style="color:#ff0000;">必须是已关注此公众账号的微信号</span>用户预约、团购报名、领取红包信息将会推送到此微信号</span>
            </td>
        </tr>
        <tr>
            <th>公众号认证文件 :</th>
            <td>
                <input type="text" name="" id="J_file" value=""  class="input-text fl mr10" size="50">
                <div id="J_weixin_upload_file" class="btn" onclick="ajaxUploadFile('J_weixin_upload_file','J_file');"><span>上传</span></div><br />
                公众号设置网页授权回调域名时，提示需要上传认证文件。请下载下来，并在此处上传。
            </td>
        </tr>
        <tr>
        	<th></th>
        	<td>
				<input type="hidden" name="name" value="{$action_name}">
                <input type="submit" class="btn btn_submit" value="提交"/>
            </td>
    	</tr>
        <tr>
            <td colspan="2">
                1、登录微信公众平台:左侧菜单->开发->基本配置：填入对应的appid,appsecrect 修改服务器配置 填写服务器接口url地址({empty name='auth_url'}<a href="{:url('Setting/index',['type'=>'site'])}">请先设置站点域名</a>{else /}{$auth_url}{/empty})<br />
                填写Token,EncodingAESKey(这两者必需要填写正确，可在公众平台随机生成保存后再填写到网站配置中)，保存公众平台配置后，点击启用按钮，接口配置才会生效。
                <p>
                    2、登录微信公众平台:左侧菜单->设置->公众号设置->功能设置->网页授权域名：填写域名({:config('url_domain_root')})，下载验证文件在本站上传。
                </p>
                <p>
                    <img src="__IMG__/wx_setting.jpg" alt=""><br />
                    <img src="__IMG__/wx_auth.jpg" alt="">
                </p>
            </td>
        </tr>
	</table>
	</form>
		</div>
</div>
</div>
</div>
{include file="public:footer" /}
<script src="__PUBLIC__/js/plugins/fileuploader.js"></script>
<script>
    function ajaxUploadFile(btn,input){
        //上传文件

        var img_uploader = new qq.FileUploaderBasic({
            allowedExtensions: ['txt'],
            button: document.getElementById(btn),
            multiple: false,
            action: "{:url('Setting/ajaxUploadFile')}",
            inputName: 'file',
            forceMultipart: true, //用$_FILES
            messages: {
                typeError: "{file} 文件类型不符合: {extensions}.",
                sizeError: "{file} 太大了, 最大不超过 {sizeLimit}.",
                minSizeError: "{file} is too small, minimum file size is {minSizeLimit}.",
                emptyError: "{file} is empty, please select files again without it.",
                noFilesError: "No files to upload.",
                onLeave: "The files are being uploaded, if you leave now the upload will be cancelled."
            },
            showMessage: function(message){
                layer.msg(message,{icon:2});
            },
            onSubmit: function(id, fileName){
                $('#'+btn).addClass('btn_disabled').find('span').text('上传中，请稍候...');
            },
            onComplete: function(id, fileName, result){
                $('#'+btn).removeClass('btn_disabled').find('span').text('上传');
                if(result.status == '1'){
                    $('#'+input).val(result.data);
                } else {
                    layer.msg(result.msg,{icon:2});
                }
            }
        });
    }
</script>
</body>
</html>